package concurrency.reentrantLock;

import java.util.concurrent.locks.ReentrantLock;

public class ReentrantLockTest {

    private static ReentrantLock lock = new ReentrantLock();

    public static void main(String[] args) {
        //可重入
        try {
            lock.lock();
            System.out.println("进入了main");
            m1();
        } finally {
            lock.unlock();
        }
    }

    public static void m1(){
        try {
            lock.lock();
            System.out.println("进入了m1");
            m2();
        } finally {
            lock.unlock();
        }
    }
    public static void m2(){
        try {
            lock.lock();
            System.out.println("进入了m2");
        } finally {
            lock.unlock();
        }
    }
}
